package com.remote.tencent.api;

import com.alibaba.fastjson.JSONObject;
import feign.Headers;
import feign.Request;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;



/**
 * @ClassName TecentMapFeign
 * @Author xiongzw
 * @Date 2023/12/22 9:12
 * @Description //腾讯地图接口api调用
 * @Version: 1.0
 **/

@FeignClient(name = "TecentMapFeign", url = "https://apis.map.qq.com", configuration = {FeignTimeoutConfig.class})
public interface TecentMapFeign {


    /**
     * 请求客户的接口
     * @param key 开发密钥（Key）
     * @param location 经纬度（GCJ02坐标系），格式：location=lat<纬度>,lng<经度>
     * @return
     */
    @RequestMapping(value = "/ws/geocoder/v1/", method = RequestMethod.GET)
    @Headers(value = "Content-Type: application/json")
    JSONObject reverseParseAddress(@RequestParam("key") String key, @RequestParam("location") String location);

}

@Configuration
class FeignTimeoutConfig {
    @Bean
    Request.Options feignOptions() {
        return new Request.Options(10 * 1000, 10 * 1000);
    }

}


